﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GbmpModel.h"
#include "IElementVisibilityFilter.h"
#include "DbDataSchema.h"

namespace gcmp
{
    class IElement;

    class GBMP_MODEL_EXPORT ElementsVisibleInLayoutFilter : public NdbObjectSchematic, public IElementVisibilityFilter
    {
        // 规避文件升级问题，该filter从SDK移到GBMP后，保留原来的GUID。// 新GUID: DED17245 - 878B - 4280 - 966A - 1873EC2DC26D
        DBOBJECT_DATA_BEGIN_AND_QUICK_CAST_FROM(gcmp, ElementsVisibleInLayoutFilter, gcmp::NdbObjectSchematic, 3C6F5672 - 6B21 - 4B1D - B296 - 7827451D3EA9, gbmpmodel, gcmp::IElementVisibilityFilter)
            DATA(Bool, IsFilterEnabled)
        DBOBJECT_DATA_END

    public:
        virtual const std::wstring& GetUniqueName() const override;

        virtual bool IsElementVisible(const IModelView* pModelView, const IElement* pElement) const override;
        virtual bool IsElementEditable(const IModelView* pModelView, const IElement* pElement) const override;
        virtual void EnableFilter(bool enable) override;
        virtual bool IsFilterEnabled() const override;

    public: //实现NdbObject接口
        virtual NdbObject* GetTopOwnerObject() const override
        {
            return nullptr;
        }
    };
}
